<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Promise-封装AJAX</title>
  <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<script>
    // axios 本身使用了 Promise封装
  // 配置url
  axios.defaults.baseURL = 'http://127.0.0.1:9000'
  axios.get('/', {
    //url参数
    params: {
      username: 'admin',
      password: 'admin'
    },
    //设置请求头
    herders: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }).then(response => {
    console.log('成功！')
    console.log(response.data)
  }).catch(err => {
    console.log('失败！' + err)
  })
</script>
</body>
</html>